package com.jdls.web;
import com.jdls.config.SpringmvcConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;

/**
 * @author 嘉德罗斯
 * @date 2021/9/15
 */
public class ServletConfig extends AbstractDispatcherServletInitializer {

    //加载springmvc配置类        产生springmvc容器
    protected WebApplicationContext createServletApplicationContext() {
        AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
        //加载指定配置类
        ctx.register(SpringmvcConfig.class);
        return ctx;
    }
    //设置springmvc控制器请求的映射路径
    //return new String[]{"/"}代表所有路径
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
    // 加载springmvc配置类
    protected WebApplicationContext createRootApplicationContext() {
        return null;
    }
}
